package com.lianniu.web.tea.token.scheduled;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.lianniu.web.tea.token.model.TeaAccessToken;
import com.lianniu.web.tea.token.service.TeaAccessTokenService;
import com.lianniu.web.tea.token.util.WeixinUtil;


@Component
public class ScheduledTest {
	private static final Logger logger = LoggerFactory.getLogger(ScheduledTest.class);

	private static final String appId = "wxb0f5fe89c5840bf4";
	// 第三方用户唯一凭证密钥
	private static final String appSecret = "f5d9e0b78ca03c83d72323eded7b3876";

	@Autowired
	private TeaAccessTokenService teaAccessTokenService;
	
	@Scheduled(cron = "0 0 0/1 * * ?")
	public void executeFileDownLoadTask() {
		TeaAccessToken accessToken = WeixinUtil.getAccessToken(appId, appSecret);
		TeaAccessToken jsapiTicket = WeixinUtil.getJsapiTicket(accessToken.getAccessTocken());
		logger.info("accessToken:"+accessToken.getAccessTocken());
		teaAccessTokenService.saveToken(accessToken,jsapiTicket);
	}
}
